import json
import os


def merge_dict(dict1, dict2):
    return {**dict1, **dict2}


def load_data_lib(file_dir):
    data_lib = {}

    for root, dirs, files in os.walk(file_dir):
        for file in files:
            file_path = os.path.join(root, file)
            with open(file_path, 'r', encoding='utf8') as fin:
                data_lib = merge_dict(data_lib, json.load(fin))
    return data_lib


if __name__ == '__main__':
    text = '胸廓不对称，气管右偏。双肺野清晰，未见明显实质性浸润。心影呈普大型，心胸比例大于0.52，心膈面延长。膈肌光滑，肋膈角锐利。'
    data_lib = load_data_lib(file_dir='./lib')

    classification_list = []
    for k, natural_sentence_list in data_lib.items():
        for natural_sentence in natural_sentence_list:
            if natural_sentence in text:
                classification_list.append(k)
                break

    print(classification_list)
